/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package inventorymanagement;

/**
 *
 * @author Administrator
 */

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class Login extends JFrame implements ActionListener
{
 JButton SUBMIT;
 JPanel panel;
 JLabel label1,label2;
 final JTextField  text1,text2;
  Login()
  {
    label1 = new JLabel();
    label1.setText("Username:");
    text1 = new JTextField(15);

    label2 = new JLabel();
    label2.setText("Password:");
      text2 = new JPasswordField(15);
 
    SUBMIT=new JButton("SUBMIT");
    
    panel=new JPanel(new GridLayout(3,1));
    panel.add(label1);
    panel.add(text1);
    panel.add(label2);
    panel.add(text2);
    panel.add(SUBMIT);
    add(panel,BorderLayout.CENTER);
    SUBMIT.addActionListener(this);
    setTitle("LOGIN FORM");
  }
   public void actionPerformed(ActionEvent ae)
  {
   
  
    String value1=text1.getText();
    String value2=text2.getText();
    
    
        if (value1.equals("sais") && value2.equals("sais")) {
           
	    setVisible(false);
             dispose();
            NextPage page=new NextPage();
   // page.setVisible(true);
   // JLabel label = new JLabel("Welcome:"+value1);
       // page.getContentPane().add(label);
  }
    else{
      System.out.println("enter the valid username and password");
      JOptionPane.showMessageDialog(this,"Incorrect login or password",
            "Error",JOptionPane.ERROR_MESSAGE);
  }
}
   
}
 class LoginDemo
{
  public static void main(String arg[])
  {
    try
    {
    Login frame=new Login();
    frame.setSize(300,100);
    frame.setVisible(true);
  
    
 //   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
  catch(Exception e)
    {JOptionPane.showMessageDialog(null, e.getMessage());}
  }
}